<template>
  <div>
    <div class="d-flex mb-3 justify-content-end">
      <button
        v-if="customerData.project_status === '0' || customerData.project_status === '2'"
        class="btn btn-outline-primary"
        @click="eidt"
      >
        <i class="fa fa-edit"></i>
        修改
      </button>
    </div>

    <loading-wrap>
      <div>
        <h5 class="text-center">资产负债表</h5>
      </div>
      <div class="text-right">单位： （元）</div>
      <table class="table table-bordered bg-white">
        <colgroup>
          <col width="12%" />
          <col width="12%" />
          <col width="12%" />
          <col width="8%" />
          <col width="12%" />
          <col width="8%" />
          <col width="15%" />
          <col width="12%" />
        </colgroup>
        <tr>
          <td></td>
          <td>
            <el-date-picker
              v-if="!DoEdit"
              v-model="data[0].report_date"
              align="right"
              placeholder="选择日期"
              style="width: 100%"
              type="month"
              :clearable="false"
              value-format="yyyy.MM"
            ></el-date-picker>
            <span v-else>{{ $utils.dateFormat(data[0].report_date, 'yyyy年M月') }}</span>
          </td>
          <td>
            <el-date-picker
              v-if="!DoEdit"
              v-model="data[1].report_date"
              align="right"
              placeholder="选择年"
              style="width: 100%"
              type="year"
              :clearable="false"
              :disabled="!data[0].report_date"
              :picker-options="{ disabledDate: d => disabledDate(d, 0) }"
              value-format="yyyy"
            ></el-date-picker>
            <span v-else>{{ data[1].report_date | pureUnit('年') }}</span>
          </td>
          <td>变动额</td>
          <td>
            <el-date-picker
              v-if="!DoEdit"
              v-model="data[2].report_date"
              align="right"
              placeholder="选择年"
              style="width: 100%"
              type="year"
              :clearable="false"
              :disabled="!data[1].report_date"
              :picker-options="{ disabledDate: d => disabledDate(d, 1) }"
              value-format="yyyy"
            ></el-date-picker>
            <span v-else>{{ data[2].report_date | pureUnit('年') }}</span>
          </td>
          <td>变动额</td>
          <td>
            <el-date-picker
              v-if="!DoEdit"
              v-model="data[3].report_date"
              align="right"
              placeholder="选择年"
              style="width: 100%"
              type="year"
              :clearable="false"
              :disabled="!data[2].report_date"
              :picker-options="{ disabledDate: d => disabledDate(d, 2) }"
              value-format="yyyy"
            ></el-date-picker>
            <span v-else>{{ data[3].report_date | pureUnit('年') }}</span>
          </td>
        </tr>
        <tr>
          <td>货币资金</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].currency"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].currency }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].currency"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].currency }}</span>
          </td>
          <td>
            {{ (data[1].currency || 0) - (data[2].currency || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].currency"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].currency }}</span>
          </td>
          <td>
            {{ (data[2].currency || 0) - (data[3].currency || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].currency"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].currency }}</span>
          </td>
        </tr>
        <tr>
          <td>应收账款</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].receivables"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].receivables }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].receivables"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].receivables }}</span>
          </td>
          <td>
            {{ (data[1].receivables || 0) - (data[2].receivables || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].receivables"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].receivables }}</span>
          </td>
          <td>
            {{ (data[2].receivables || 0) - (data[3].receivables || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].receivables"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].receivables }}</span>
          </td>
        </tr>
        <tr>
          <td>预付账款</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].pre_charge"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].pre_charge }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].pre_charge"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].pre_charge }}</span>
          </td>
          <td>
            {{ (data[1].pre_charge || 0) - (data[2].pre_charge || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].pre_charge"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].pre_charge }}</span>
          </td>
          <td>
            {{ (data[2].pre_charge || 0) - (data[3].pre_charge || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].pre_charge"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].pre_charge }}</span>
          </td>
        </tr>
        <tr>
          <td>存货</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].stock"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].stock }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].stock"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].stock }}</span>
          </td>
          <td>
            {{ (data[1].stock || 0) - (data[2].stock || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].stock"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].stock }}</span>
          </td>
          <td>
            {{ (data[2].stock || 0) - (data[3].stock || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].stock"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].stock }}</span>
          </td>
        </tr>
        <tr>
          <td>其他应收款</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].other_receivables"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].other_receivables }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].other_receivables"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].other_receivables }}</span>
          </td>
          <td>
            {{ (data[1].other_receivables || 0) - (data[2].other_receivables || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].other_receivables"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].other_receivables }}</span>
          </td>
          <td>
            {{ (data[2].other_receivables || 0) - (data[3].other_receivables || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].other_receivables"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].other_receivables }}</span>
          </td>
        </tr>
        <tr>
          <td>其他流动资产</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].other_current_assets"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].other_current_assets }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].other_current_assets"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].other_current_assets }}</span>
          </td>
          <td>
            {{ (data[1].other_current_assets || 0) - (data[2].other_current_assets || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].other_current_assets"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].other_current_assets }}</span>
          </td>
          <td>
            {{ (data[2].other_current_assets || 0) - (data[3].other_current_assets || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].other_current_assets"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].other_current_assets }}</span>
          </td>
        </tr>
        <tr>
          <td>流动资产小计</td>
          <td>
            {{
              (parseFloat(data[0].currency) || 0) +
              (parseFloat(data[0].receivables) || 0) +
              (parseFloat(data[0].pre_charge) || 0) +
              (parseFloat(data[0].stock) || 0) +
              (parseFloat(data[0].other_receivables) || 0) +
              (parseFloat(data[0].other_current_assets) || 0)
            }}
          </td>
          <td>
            {{
              (parseFloat(data[1].currency) || 0) +
              (parseFloat(data[1].receivables) || 0) +
              (parseFloat(data[1].pre_charge) || 0) +
              (parseFloat(data[1].stock) || 0) +
              (parseFloat(data[1].other_receivables) || 0) +
              (parseFloat(data[1].other_current_assets) || 0)
            }}
          </td>
          <td>
            {{
              [
                (parseFloat(data[1].currency) || 0) +
                  (parseFloat(data[1].receivables) || 0) +
                  (parseFloat(data[1].pre_charge) || 0) +
                  (parseFloat(data[1].stock) || 0) +
                  (parseFloat(data[1].other_receivables) || 0) +
                  (parseFloat(data[1].other_current_assets) || 0),
              ] -
              [
                (parseFloat(data[2].currency) || 0) +
                  (parseFloat(data[2].receivables) || 0) +
                  (parseFloat(data[2].pre_charge) || 0) +
                  (parseFloat(data[2].stock) || 0) +
                  (parseFloat(data[2].other_receivables) || 0) +
                  (parseFloat(data[2].other_current_assets) || 0),
              ]
            }}
          </td>
          <td>
            {{
              (parseFloat(data[2].currency) || 0) +
              (parseFloat(data[2].receivables) || 0) +
              (parseFloat(data[2].pre_charge) || 0) +
              (parseFloat(data[2].stock) || 0) +
              (parseFloat(data[2].other_receivables) || 0) +
              (parseFloat(data[2].other_current_assets) || 0)
            }}
          </td>
          <td>
            {{
              [
                (parseFloat(data[2].currency) || 0) +
                  (parseFloat(data[2].receivables) || 0) +
                  (parseFloat(data[2].pre_charge) || 0) +
                  (parseFloat(data[2].stock) || 0) +
                  (parseFloat(data[2].other_receivables) || 0) +
                  (parseFloat(data[2].other_current_assets) || 0),
              ] -
              [
                (parseFloat(data[3].currency) || 0) +
                  (parseFloat(data[3].receivables) || 0) +
                  (parseFloat(data[3].pre_charge) || 0) +
                  (parseFloat(data[3].stock) || 0) +
                  (parseFloat(data[3].other_receivables) || 0) +
                  (parseFloat(data[3].other_current_assets) || 0),
              ]
            }}
          </td>
          <td>
            {{
              (parseFloat(data[3].currency) || 0) +
              (parseFloat(data[3].receivables) || 0) +
              (parseFloat(data[3].pre_charge) || 0) +
              (parseFloat(data[3].stock) || 0) +
              (parseFloat(data[3].other_receivables) || 0) +
              (parseFloat(data[3].other_current_assets) || 0)
            }}
          </td>
        </tr>
        <tr>
          <td>长期投资</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].long_invest"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].long_invest }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].long_invest"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].long_invest }}</span>
          </td>
          <td>
            {{ (data[1].long_invest || 0) - (data[2].long_invest || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].long_invest"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].long_invest }}</span>
          </td>
          <td>
            {{ (data[2].long_invest || 0) - (data[3].long_invest || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].long_invest"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].long_invest }}</span>
          </td>
        </tr>
        <tr>
          <td>固定资产净额</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].net_fixed_assets"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].net_fixed_assets }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].net_fixed_assets"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].net_fixed_assets }}</span>
          </td>
          <td>
            {{ (data[1].net_fixed_assets || 0) - (data[2].net_fixed_assets || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].net_fixed_assets"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].net_fixed_assets }}</span>
          </td>
          <td>
            {{ (data[2].net_fixed_assets || 0) - (data[3].net_fixed_assets || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].net_fixed_assets"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].net_fixed_assets }}</span>
          </td>
        </tr>
        <tr>
          <td>在建工程</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].const_project"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].const_project }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].const_project"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].const_project }}</span>
          </td>
          <td>
            {{ (data[1].const_project || 0) - (data[2].const_project || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].const_project"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].const_project }}</span>
          </td>
          <td>
            {{ (data[2].const_project || 0) - (data[3].const_project || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].const_project"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].const_project }}</span>
          </td>
        </tr>
        <tr>
          <td>无形资产净额</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].net_intangible_assets"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].net_intangible_assets }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].net_intangible_assets"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].net_intangible_assets }}</span>
          </td>
          <td>
            {{ (data[1].net_intangible_assets || 0) - (data[2].net_intangible_assets || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].net_intangible_assets"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].net_intangible_assets }}</span>
          </td>
          <td>
            {{ (data[2].net_intangible_assets || 0) - (data[3].net_intangible_assets || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].net_intangible_assets"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].net_intangible_assets }}</span>
          </td>
        </tr>
        <tr>
          <td>固定资产小计</td>
          <td>
            {{
              (parseFloat(data[0].long_invest) || 0) +
              (parseFloat(data[0].net_fixed_assets) || 0) +
              (parseFloat(data[0].const_project) || 0) +
              (parseFloat(data[0].net_intangible_assets) || 0)
            }}
          </td>
          <td>
            {{
              (parseFloat(data[1].long_invest) || 0) +
              (parseFloat(data[1].net_fixed_assets) || 0) +
              (parseFloat(data[1].const_project) || 0) +
              (parseFloat(data[1].net_intangible_assets) || 0)
            }}
          </td>
          <td>
            {{
              [
                (parseFloat(data[1].long_invest) || 0) +
                  (parseFloat(data[1].net_fixed_assets) || 0) +
                  (parseFloat(data[1].const_project) || 0) +
                  (parseFloat(data[1].net_intangible_assets) || 0),
              ] -
              [
                (parseFloat(data[2].long_invest) || 0) +
                  (parseFloat(data[2].net_fixed_assets) || 0) +
                  (parseFloat(data[2].const_project) || 0) +
                  (parseFloat(data[2].net_intangible_assets) || 0),
              ]
            }}
          </td>
          <td>
            {{
              (parseFloat(data[2].long_invest) || 0) +
              (parseFloat(data[2].net_fixed_assets) || 0) +
              (parseFloat(data[2].const_project) || 0) +
              (parseFloat(data[2].net_intangible_assets) || 0)
            }}
          </td>
          <td>
            {{
              [
                (parseFloat(data[2].long_invest) || 0) +
                  (parseFloat(data[2].net_fixed_assets) || 0) +
                  (parseFloat(data[2].const_project) || 0) +
                  (parseFloat(data[2].net_intangible_assets) || 0),
              ] -
              [
                (parseFloat(data[3].long_invest) || 0) +
                  (parseFloat(data[3].net_fixed_assets) || 0) +
                  (parseFloat(data[3].const_project) || 0) +
                  (parseFloat(data[3].net_intangible_assets) || 0),
              ]
            }}
          </td>
          <td>
            {{
              (parseFloat(data[3].long_invest) || 0) +
              (parseFloat(data[3].net_fixed_assets) || 0) +
              (parseFloat(data[3].const_project) || 0) +
              (parseFloat(data[3].net_intangible_assets) || 0)
            }}
          </td>
        </tr>
        <tr>
          <td>资产合计</td>
          <td>
            {{
              (parseFloat(data[0].currency) || 0) +
              (parseFloat(data[0].receivables) || 0) +
              (parseFloat(data[0].pre_charge) || 0) +
              (parseFloat(data[0].stock) || 0) +
              (parseFloat(data[0].other_receivables) || 0) +
              (parseFloat(data[0].other_current_assets) || 0) +
              (parseFloat(data[0].long_invest) || 0) +
              (parseFloat(data[0].net_fixed_assets) || 0) +
              (parseFloat(data[0].const_project) || 0) +
              (parseFloat(data[0].net_intangible_assets) || 0)
            }}
          </td>
          <td>
            {{
              (parseFloat(data[1].currency) || 0) +
              (parseFloat(data[1].receivables) || 0) +
              (parseFloat(data[1].pre_charge) || 0) +
              (parseFloat(data[1].stock) || 0) +
              (parseFloat(data[1].other_receivables) || 0) +
              (parseFloat(data[1].other_current_assets) || 0) +
              (parseFloat(data[1].long_invest) || 0) +
              (parseFloat(data[1].net_fixed_assets) || 0) +
              (parseFloat(data[1].const_project) || 0) +
              (parseFloat(data[1].net_intangible_assets) || 0)
            }}
          </td>
          <td>
            {{
              [
                (parseFloat(data[1].currency) || 0) +
                  (parseFloat(data[1].receivables) || 0) +
                  (parseFloat(data[1].pre_charge) || 0) +
                  (parseFloat(data[1].stock) || 0) +
                  (parseFloat(data[1].other_receivables) || 0) +
                  (parseFloat(data[1].other_current_assets) || 0) +
                  (parseFloat(data[1].long_invest) || 0) +
                  (parseFloat(data[1].net_fixed_assets) || 0) +
                  (parseFloat(data[1].const_project) || 0) +
                  (parseFloat(data[1].net_intangible_assets) || 0),
              ] -
              [
                (parseFloat(data[2].currency) || 0) +
                  (parseFloat(data[2].receivables) || 0) +
                  (parseFloat(data[2].pre_charge) || 0) +
                  (parseFloat(data[2].stock) || 0) +
                  (parseFloat(data[2].other_receivables) || 0) +
                  (parseFloat(data[2].other_current_assets) || 0) +
                  (parseFloat(data[2].long_invest) || 0) +
                  (parseFloat(data[2].net_fixed_assets) || 0) +
                  (parseFloat(data[2].const_project) || 0) +
                  (parseFloat(data[2].net_intangible_assets) || 0),
              ]
            }}
          </td>
          <td>
            {{
              (parseFloat(data[2].currency) || 0) +
              (parseFloat(data[2].receivables) || 0) +
              (parseFloat(data[2].pre_charge) || 0) +
              (parseFloat(data[2].stock) || 0) +
              (parseFloat(data[2].other_receivables) || 0) +
              (parseFloat(data[2].other_current_assets) || 0) +
              (parseFloat(data[2].long_invest) || 0) +
              (parseFloat(data[2].net_fixed_assets) || 0) +
              (parseFloat(data[2].const_project) || 0) +
              (parseFloat(data[2].net_intangible_assets) || 0)
            }}
          </td>
          <td>
            {{
              [
                (parseFloat(data[2].currency) || 0) +
                  (parseFloat(data[2].receivables) || 0) +
                  (parseFloat(data[2].pre_charge) || 0) +
                  (parseFloat(data[2].stock) || 0) +
                  (parseFloat(data[2].other_receivables) || 0) +
                  (parseFloat(data[2].other_current_assets) || 0) +
                  (parseFloat(data[2].long_invest) || 0) +
                  (parseFloat(data[2].net_fixed_assets) || 0) +
                  (parseFloat(data[2].const_project) || 0) +
                  (parseFloat(data[2].net_intangible_assets) || 0),
              ] -
              [
                (parseFloat(data[3].currency) || 0) +
                  (parseFloat(data[3].receivables) || 0) +
                  (parseFloat(data[3].pre_charge) || 0) +
                  (parseFloat(data[3].stock) || 0) +
                  (parseFloat(data[3].other_receivables) || 0) +
                  (parseFloat(data[3].other_current_assets) || 0) +
                  (parseFloat(data[3].long_invest) || 0) +
                  (parseFloat(data[3].net_fixed_assets) || 0) +
                  (parseFloat(data[3].const_project) || 0) +
                  (parseFloat(data[3].net_intangible_assets) || 0),
              ]
            }}
          </td>
          <td>
            {{
              (parseFloat(data[3].currency) || 0) +
              (parseFloat(data[3].receivables) || 0) +
              (parseFloat(data[3].pre_charge) || 0) +
              (parseFloat(data[3].stock) || 0) +
              (parseFloat(data[3].other_receivables) || 0) +
              (parseFloat(data[3].other_current_assets) || 0) +
              (parseFloat(data[3].long_invest) || 0) +
              (parseFloat(data[3].net_fixed_assets) || 0) +
              (parseFloat(data[3].const_project) || 0) +
              (parseFloat(data[3].net_intangible_assets) || 0)
            }}
          </td>
        </tr>
        <tr>
          <td>短期借款</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].short_load"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].short_load }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].short_load"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].short_load }}</span>
          </td>
          <td>
            {{ (data[1].short_load || 0) - (data[2].short_load || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].short_load"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].short_load }}</span>
          </td>
          <td>
            {{ (data[2].short_load || 0) - (data[3].short_load || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].short_load"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].short_load }}</span>
          </td>
        </tr>
        <tr>
          <td>应付账款</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].should_charge"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].should_charge }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].should_charge"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].should_charge }}</span>
          </td>
          <td>
            {{ (data[1].should_charge || 0) - (data[2].should_charge || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].should_charge"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].should_charge }}</span>
          </td>
          <td>
            {{ (data[2].should_charge || 0) - (data[3].should_charge || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].should_charge"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].should_charge }}</span>
          </td>
        </tr>
        <tr>
          <td>预收账款</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].pre_receivables"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].pre_receivables }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].pre_receivables"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].pre_receivables }}</span>
          </td>
          <td>
            {{ (data[1].pre_receivables || 0) - (data[2].pre_receivables || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].pre_receivables"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].pre_receivables }}</span>
          </td>
          <td>
            {{ (data[2].pre_receivables || 0) - (data[3].pre_receivables || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].pre_receivables"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].pre_receivables }}</span>
          </td>
        </tr>
        <tr>
          <td>其他应付款</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].other_should_charge"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].other_should_charge }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].other_should_charge"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].other_should_charge }}</span>
          </td>
          <td>
            {{ (data[1].other_should_charge || 0) - (data[2].other_should_charge || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].other_should_charge"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].other_should_charge }}</span>
          </td>
          <td>
            {{ (data[2].other_should_charge || 0) - (data[3].other_should_charge || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].other_should_charge"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].other_should_charge }}</span>
          </td>
        </tr>
        <tr>
          <td>其他流动负债</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].other_current_debt"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].other_current_debt }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].other_current_debt"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].other_current_debt }}</span>
          </td>
          <td>
            {{ (data[1].other_current_debt || 0) - (data[2].other_current_debt || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].other_current_debt"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].other_current_debt }}</span>
          </td>
          <td>
            {{ (data[2].other_current_debt || 0) - (data[3].other_current_debt || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].other_current_debt"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].other_current_debt }}</span>
          </td>
        </tr>
        <tr>
          <td>长期负债</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].long_debt"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].long_debt }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].long_debt"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].long_debt }}</span>
          </td>
          <td>
            {{ (data[1].long_debt || 0) - (data[2].long_debt || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].long_debt"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].long_debt }}</span>
          </td>
          <td>
            {{ (data[2].long_debt || 0) - (data[3].long_debt || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].long_debt"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].long_debt }}</span>
          </td>
        </tr>
        <tr>
          <td>负债小计</td>
          <td>
            {{
              (parseFloat(data[0].short_load) || 0) +
              (parseFloat(data[0].should_charge) || 0) +
              (parseFloat(data[0].pre_receivables) || 0) +
              (parseFloat(data[0].other_should_charge) || 0) +
              (parseFloat(data[0].other_current_debt) || 0) +
              (parseFloat(data[0].long_debt) || 0)
            }}
          </td>
          <td>
            {{
              (parseFloat(data[1].short_load) || 0) +
              (parseFloat(data[1].should_charge) || 0) +
              (parseFloat(data[1].pre_receivables) || 0) +
              (parseFloat(data[1].other_should_charge) || 0) +
              (parseFloat(data[1].other_current_debt) || 0) +
              (parseFloat(data[1].long_debt) || 0)
            }}
          </td>
          <td>
            {{
              [
                (parseFloat(data[1].short_load) || 0) +
                  (parseFloat(data[1].should_charge) || 0) +
                  (parseFloat(data[1].pre_receivables) || 0) +
                  (parseFloat(data[1].other_should_charge) || 0) +
                  (parseFloat(data[1].other_current_debt) || 0) +
                  (parseFloat(data[1].long_debt) || 0),
              ] -
              [
                (parseFloat(data[2].short_load) || 0) +
                  (parseFloat(data[2].should_charge) || 0) +
                  (parseFloat(data[2].pre_receivables) || 0) +
                  (parseFloat(data[2].other_should_charge) || 0) +
                  (parseFloat(data[2].other_current_debt) || 0) +
                  (parseFloat(data[2].long_debt) || 0),
              ]
            }}
          </td>
          <td>
            {{
              (parseFloat(data[2].short_load) || 0) +
              (parseFloat(data[2].should_charge) || 0) +
              (parseFloat(data[2].pre_receivables) || 0) +
              (parseFloat(data[2].other_should_charge) || 0) +
              (parseFloat(data[2].other_current_debt) || 0) +
              (parseFloat(data[2].long_debt) || 0)
            }}
          </td>
          <td>
            {{
              [
                (parseFloat(data[2].short_load) || 0) +
                  (parseFloat(data[2].should_charge) || 0) +
                  (parseFloat(data[2].pre_receivables) || 0) +
                  (parseFloat(data[2].other_should_charge) || 0) +
                  (parseFloat(data[2].other_current_debt) || 0) +
                  (parseFloat(data[2].long_debt) || 0),
              ] -
              [
                (parseFloat(data[3].short_load) || 0) +
                  (parseFloat(data[3].should_charge) || 0) +
                  (parseFloat(data[3].pre_receivables) || 0) +
                  (parseFloat(data[3].other_should_charge) || 0) +
                  (parseFloat(data[3].other_current_debt) || 0) +
                  (parseFloat(data[3].long_debt) || 0),
              ]
            }}
          </td>
          <td>
            {{
              (parseFloat(data[3].short_load) || 0) +
              (parseFloat(data[3].should_charge) || 0) +
              (parseFloat(data[3].pre_receivables) || 0) +
              (parseFloat(data[3].other_should_charge) || 0) +
              (parseFloat(data[3].other_current_debt) || 0) +
              (parseFloat(data[3].long_debt) || 0)
            }}
          </td>
        </tr>
        <tr>
          <td>实收资本或股本</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].paid_capital"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].paid_capital }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].paid_capital"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].paid_capital }}</span>
          </td>
          <td>
            {{ (data[1].paid_capital || 0) - (data[2].paid_capital || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].paid_capital"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].paid_capital }}</span>
          </td>
          <td>
            {{ (data[2].paid_capital || 0) - (data[3].paid_capital || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].paid_capital"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].paid_capital }}</span>
          </td>
        </tr>
        <tr>
          <td>资本公积</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].capital_reserve"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].capital_reserve }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].capital_reserve"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].capital_reserve }}</span>
          </td>
          <td>
            {{ (data[1].capital_reserve || 0) - (data[2].capital_reserve || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].capital_reserve"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].capital_reserve }}</span>
          </td>
          <td>
            {{ (data[2].capital_reserve || 0) - (data[3].capital_reserve || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].capital_reserve"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].capital_reserve }}</span>
          </td>
        </tr>
        <tr>
          <td>留存收益</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].retained_earnings"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].retained_earnings }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].retained_earnings"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].retained_earnings }}</span>
          </td>
          <td>
            {{ (data[1].retained_earnings || 0) - (data[2].retained_earnings || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].retained_earnings"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].retained_earnings }}</span>
          </td>
          <td>
            {{ (data[2].retained_earnings || 0) - (data[3].retained_earnings || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].retained_earnings"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].retained_earnings }}</span>
          </td>
        </tr>
        <tr>
          <td>未分配利润</td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[0].und_profit"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[0].und_profit }}</span>
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[1].und_profit"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[1].und_profit }}</span>
          </td>
          <td>
            {{ (data[1].und_profit || 0) - (data[2].und_profit || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[2].und_profit"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[2].und_profit }}</span>
          </td>
          <td>
            {{ (data[2].und_profit || 0) - (data[3].und_profit || 0) || 0 }}
          </td>
          <td>
            <el-input-number
              v-if="!DoEdit"
              v-model="data[3].und_profit"
              style="width: 100%"
              :controls="false"
            ></el-input-number>
            <span v-else>{{ data[3].und_profit }}</span>
          </td>
        </tr>
        <tr>
          <td>权益小计</td>
          <td>
            {{
              (parseFloat(data[0].paid_capital) || 0) +
              (parseFloat(data[0].capital_reserve) || 0) +
              (parseFloat(data[0].retained_earnings) || 0) +
              (parseFloat(data[0].und_profit) || 0)
            }}
          </td>
          <td>
            {{
              (parseFloat(data[1].paid_capital) || 0) +
              (parseFloat(data[1].capital_reserve) || 0) +
              (parseFloat(data[1].retained_earnings) || 0) +
              (parseFloat(data[1].und_profit) || 0)
            }}
          </td>
          <td>
            {{
              [
                (parseFloat(data[1].paid_capital) || 0) +
                  (parseFloat(data[1].capital_reserve) || 0) +
                  (parseFloat(data[1].retained_earnings) || 0) +
                  (parseFloat(data[1].und_profit) || 0),
              ] -
              [
                (parseFloat(data[2].paid_capital) || 0) +
                  (parseFloat(data[2].capital_reserve) || 0) +
                  (parseFloat(data[2].retained_earnings) || 0) +
                  (parseFloat(data[2].und_profit) || 0),
              ]
            }}
          </td>
          <td>
            {{
              (parseFloat(data[2].paid_capital) || 0) +
              (parseFloat(data[2].capital_reserve) || 0) +
              (parseFloat(data[2].retained_earnings) || 0) +
              (parseFloat(data[2].und_profit) || 0)
            }}
          </td>
          <td>
            {{
              [
                (parseFloat(data[2].paid_capital) || 0) +
                  (parseFloat(data[2].capital_reserve) || 0) +
                  (parseFloat(data[2].retained_earnings) || 0) +
                  (parseFloat(data[2].und_profit) || 0),
              ] -
              [
                (parseFloat(data[3].paid_capital) || 0) +
                  (parseFloat(data[3].capital_reserve) || 0) +
                  (parseFloat(data[3].retained_earnings) || 0) +
                  (parseFloat(data[3].und_profit) || 0),
              ]
            }}
          </td>
          <td>
            {{
              (parseFloat(data[3].paid_capital) || 0) +
              (parseFloat(data[3].capital_reserve) || 0) +
              (parseFloat(data[3].retained_earnings) || 0) +
              (parseFloat(data[3].und_profit) || 0)
            }}
          </td>
        </tr>
        <tr>
          <td>负债与所有者权益合计</td>
          <td>
            {{
              (parseFloat(data[0].short_load) || 0) +
              (parseFloat(data[0].should_charge) || 0) +
              (parseFloat(data[0].pre_receivables) || 0) +
              (parseFloat(data[0].other_should_charge) || 0) +
              (parseFloat(data[0].other_current_debt) || 0) +
              (parseFloat(data[0].long_debt) || 0) +
              (parseFloat(data[0].paid_capital) || 0) +
              (parseFloat(data[0].capital_reserve) || 0) +
              (parseFloat(data[0].retained_earnings) || 0) +
              (parseFloat(data[0].und_profit) || 0)
            }}
          </td>
          <td>
            {{
              (parseFloat(data[1].short_load) || 0) +
              (parseFloat(data[1].should_charge) || 0) +
              (parseFloat(data[1].pre_receivables) || 0) +
              (parseFloat(data[1].other_should_charge) || 0) +
              (parseFloat(data[1].other_current_debt) || 0) +
              (parseFloat(data[1].long_debt) || 0) +
              (parseFloat(data[1].paid_capital) || 0) +
              (parseFloat(data[1].capital_reserve) || 0) +
              (parseFloat(data[1].retained_earnings) || 0) +
              (parseFloat(data[1].und_profit) || 0)
            }}
          </td>
          <td>
            {{
              [
                (parseFloat(data[1].short_load) || 0) +
                  (parseFloat(data[1].should_charge) || 0) +
                  (parseFloat(data[1].pre_receivables) || 0) +
                  (parseFloat(data[1].other_should_charge) || 0) +
                  (parseFloat(data[1].other_current_debt) || 0) +
                  (parseFloat(data[1].long_debt) || 0) +
                  (parseFloat(data[1].paid_capital) || 0) +
                  (parseFloat(data[1].capital_reserve) || 0) +
                  (parseFloat(data[1].retained_earnings) || 0) +
                  (parseFloat(data[1].und_profit) || 0),
              ] -
              [
                (parseFloat(data[2].short_load) || 0) +
                  (parseFloat(data[2].should_charge) || 0) +
                  (parseFloat(data[2].pre_receivables) || 0) +
                  (parseFloat(data[2].other_should_charge) || 0) +
                  (parseFloat(data[2].other_current_debt) || 0) +
                  (parseFloat(data[2].long_debt) || 0) +
                  (parseFloat(data[2].paid_capital) || 0) +
                  (parseFloat(data[2].capital_reserve) || 0) +
                  (parseFloat(data[2].retained_earnings) || 0) +
                  (parseFloat(data[2].und_profit) || 0),
              ]
            }}
          </td>
          <td>
            {{
              (parseFloat(data[2].short_load) || 0) +
              (parseFloat(data[2].should_charge) || 0) +
              (parseFloat(data[2].pre_receivables) || 0) +
              (parseFloat(data[2].other_should_charge) || 0) +
              (parseFloat(data[2].other_current_debt) || 0) +
              (parseFloat(data[2].long_debt) || 0) +
              (parseFloat(data[2].paid_capital) || 0) +
              (parseFloat(data[2].capital_reserve) || 0) +
              (parseFloat(data[2].retained_earnings) || 0) +
              (parseFloat(data[2].und_profit) || 0)
            }}
          </td>
          <td>
            {{
              [
                (parseFloat(data[2].short_load) || 0) +
                  (parseFloat(data[2].should_charge) || 0) +
                  (parseFloat(data[2].pre_receivables) || 0) +
                  (parseFloat(data[2].other_should_charge) || 0) +
                  (parseFloat(data[2].other_current_debt) || 0) +
                  (parseFloat(data[2].long_debt) || 0) +
                  (parseFloat(data[2].paid_capital) || 0) +
                  (parseFloat(data[2].capital_reserve) || 0) +
                  (parseFloat(data[2].retained_earnings) || 0) +
                  (parseFloat(data[2].und_profit) || 0),
              ] -
              [
                (parseFloat(data[3].short_load) || 0) +
                  (parseFloat(data[3].should_charge) || 0) +
                  (parseFloat(data[3].pre_receivables) || 0) +
                  (parseFloat(data[3].other_should_charge) || 0) +
                  (parseFloat(data[3].other_current_debt) || 0) +
                  (parseFloat(data[3].long_debt) || 0) +
                  (parseFloat(data[3].paid_capital) || 0) +
                  (parseFloat(data[3].capital_reserve) || 0) +
                  (parseFloat(data[3].retained_earnings) || 0) +
                  (parseFloat(data[3].und_profit) || 0),
              ]
            }}
          </td>
          <td>
            {{
              (parseFloat(data[3].short_load) || 0) +
              (parseFloat(data[3].should_charge) || 0) +
              (parseFloat(data[3].pre_receivables) || 0) +
              (parseFloat(data[3].other_should_charge) || 0) +
              (parseFloat(data[3].other_current_debt) || 0) +
              (parseFloat(data[3].long_debt) || 0) +
              (parseFloat(data[3].paid_capital) || 0) +
              (parseFloat(data[3].capital_reserve) || 0) +
              (parseFloat(data[3].retained_earnings) || 0) +
              (parseFloat(data[3].und_profit) || 0)
            }}
          </td>
        </tr>
      </table>
    </loading-wrap>

    <el-row v-if="!DoEdit" class="row-bg" justify="center" style="margin-top: 30px" type="flex">
      <el-col :span="6">
        <el-button style="margin-left: 15%" @click="eidt">取消</el-button>
      </el-col>
      <el-col :span="6">
        <el-button style="margin-left: 10%" @click="submit">保存</el-button>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import { enumPftype } from '@/credit/plugins/enum'

export default {
  components: {},
  props: {},
  data() {
    return {
      enumPftype,
      DoEdit: true,
      data: [{}, {}, {}, {}],
      tableData: [],
      tableName: 'datum_customer_finance_report',
    }
  },
  computed: {},
  watch: {},
  created() {
    this.customerData = JSON.parse(sessionStorage.getItem('customer_related_view'))
    this.id = this.$route.query.id || sessionStorage.getItem('customer_related_id')
    this.getData()
  },
  mounted() {},
  methods: {
    getData() {
      this.$api
        .getData(
          'credit',
          this.tableName,
          {
            'customer_related_id.eq': this.id,
          },
          { report_date: 'desc' }
        )
        .then(res => {
          if (!res.data) {
            return
          }
          this.data = res.data
        })
    },
    eidt() {
      this.DoEdit = !this.DoEdit
      if (this.DoEdit === true) {
        this.getData()
      }
    },
    async submit() {
      let postData = []
      let putData = []
      for (let p of this.data) {
        if (p.id) {
          putData.push(p)
        } else {
          postData.push(p)
        }
      }
      if (postData.length > 0) {
        for (let p of postData) {
          p.customer_id = this.customerData.customer_id
          p.customer_related_id = this.id
          p.service_id = this.customerData.service_id
        }
        const [res, err] = await this.$utils.promise(
          this.$api.addBatch('credit', 'datum_customer_finance_report', postData)
        )
        this.saveLoading = false
        if (res) {
          this.$message.success('数据采集成功！')
          this.eidt()
        } else {
          this.$message.error(`数据采集失败，请重试！（${err.status}）`)
        }
      }
      if (putData.length > 0) {
        this.putData(putData)
      }
    },
    async putData(putData) {
      let i = 0
      for (let p of putData) {
        let [res, err] = await this.$utils.promise(
          this.$api.updateData('credit', 'datum_customer_finance_report', p.id, p)
        )
        if (res) {
          i++
        } else {
          this.$message.error(`数据采集失败，请重试！（${err.status}）`)
        }
      }
      if (i === putData.length) {
        this.$message.success('数据采集成功！')
        this.eidt()
      }
    },

    disabledDate(date, index) {
      let preDate = this.data[index].report_date

      if (!preDate) {
        return true
      }

      preDate = preDate.replace(/^(\d{4}).*/, '$1')
      preDate = Number.parseInt(preDate, 10)
      return isNaN(preDate) ? true : date.getFullYear() >= preDate + (index === 0 ? 1 : 0)
    },
  },
}
</script>
<style scoped>
table {
  text-align: center;
}

table tr td {
  vertical-align: middle;
}
</style>
